package Kruskal;

import java.util.Vector;
import java.lang.Math;

public class Convertion {

	private int n;
	private int radius;
	private int centreX;
	private int centreY;
	private int angle;
	private double fi;

	public class ColoredLine {
		private int color;
		public int getColor() {
			return color;
		}
		public void setColor(int color) {
			this.color = color;
		}
		public int getX1() {
			return x1;
		}
		public void setX1(int x1) {
			this.x1 = x1;
		}
		public int getY1() {
			return y1;
		}
		public void setY1(int y1) {
			this.y1 = y1;
		}
		public int getX2() {
			return x2;
		}
		public void setX2(int x2) {
			this.x2 = x2;
		}
		public int getY2() {
			return y2;
		}
		public void setY2(int y2) {
			this.y2 = y2;
		}
		private int x1;
		private int y1;
		private int x2;
		private int y2;
	}

	public class ColoredPoint {
		private int color;
		private int x;
		private int y;
		public int getColor() {
			return color;
		}
		public void setColor(int color) {
			this.color = color;
		}
		public int getX() {
			return x;
		}
		public void setX(int x) {
			this.x = x;
		}
		public int getY() {
			return y;
		}
		public void setY(int y) {
			this.y = y;
		}
	}

	Convertion(int _n, int r, int x, int y) {
		n = _n;
		radius = r;
		centreX = x;
		centreY = y;
		angle = 360 / n;
		fi = (angle * Math.PI / 180);
	}

	public void convert(Vector<Vector<Integer>> matrix,
			Vector<Integer> vertices_color,
			Vector<Vector<Integer>> edges_color, Vector<ColoredLine> lines,
			Vector<ColoredPoint> points) {
		lines.clear();
		points.clear();

		for (int i = 0; i < n - 1; i++)
			for (int j = i + 1; j < n; j++) {
				if (matrix.get(i).get(j) != 0) {
					ColoredLine temp = new ColoredLine();
					temp.x1 = (int) (radius * Math.cos(fi * i) + centreX);
					if (Math.sin(fi * i) < 0)
						temp.y1 = (int) (Math.abs(radius * Math.sin(fi * i)) + centreY);
					else
						temp.y1 = (int) (centreY - radius * Math.sin(fi * i));
					temp.x2 = (int) (radius * Math.cos(fi * j) + centreX);
					if (Math.sin(fi * i) < 0)
						temp.y2 = (int) Math.abs(radius * Math.sin(fi * j))
								+ centreY;
					else
						temp.y2 = (int) (centreY - radius * Math.sin(fi * j));
					temp.color = edges_color.get(i).get(j);
					lines.add(temp);
				}
			}

		for (int i = 0; i < n; i++) {
			ColoredPoint temp = new ColoredPoint();
			temp.x = (int) (radius * Math.cos(fi * i) + centreX);
			if (Math.sin(fi * i) < 0)
				temp.y = (int) Math.abs(radius * Math.sin(fi * i)) + centreY;
			else
				temp.y = (int) (centreY - radius * Math.sin(fi * i));
			temp.color = vertices_color.get(i);
			points.add(temp);
		}

	}

}